/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo.grafico;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.LineString;
import java.awt.Color;
import java.awt.Font;
import java.util.List;
import modelo.primitivas.PoliLinea;
import modelo.primitivas.Punto;
import modelo.primitivas.SegmentoLinea;
import no.geosoft.cc.graphics.GObject;
import no.geosoft.cc.graphics.GPosition;
import no.geosoft.cc.graphics.GSegment;
import no.geosoft.cc.graphics.GStyle;
import no.geosoft.cc.graphics.GText;

/**
 *
 * @author Fredy
 */
public class PoliLineaGrafica extends GObject {

    private GSegment linea;
    private LineString miPoliLinea;
    private GStyle      textStyle_;

    public PoliLineaGrafica(LineString pLineString) {
        miPoliLinea = pLineString;
        linea = new GSegment();
        GStyle estilo = new GStyle();
        estilo.setForegroundColor(new Color(252, 213, 180));//219, 229, 241
        estilo.setBackgroundColor(new Color(252, 213, 180));
        estilo.setLineWidth(3);
        setStyle(estilo);
        addSegment(linea);
        setName("");
    }

    public void draw() {

        Coordinate[] coordenadas = miPoliLinea.getCoordinates();
        int size = coordenadas.length;
        double[] coordenadasX = new double[size];
        double[] coordenadasY = new double[size];

        for(int c=0; c<size; c++){
            Coordinate actual = coordenadas[c];
            coordenadasX[c] = actual.x;
            coordenadasY[c] = actual.y;
        }
        

        linea.setGeometry(
                coordenadasX, coordenadasY
                );
    }

    public void fijarTexto(String pTexto, Color pColor){
      textStyle_ = new GStyle();
      textStyle_.setForegroundColor (pColor);
      textStyle_.setFont (new Font ("Dialog", Font.BOLD, 20));

      GText text = new GText (pTexto);
      text.setPositionHint(GPosition.BOTTOM);
      text.setStyle (textStyle_);
      linea.setText(text);

    }
   
}
